<template>
  <div>
    供应商管理
    <div>
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item>
          <el-input v-model="formInline.user" placeholder="供应商名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="formInline.user" placeholder="联系人"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="formInline.user" placeholder="联系电话"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">新增</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div>
      <el-table height="350" :data="this.list" border style="width: 100%">
        <el-table-column prop="id" label="序号" width="180"> </el-table-column>
        <el-table-column prop="name" label="供应商名称" width="180"> </el-table-column>
        <el-table-column prop="linkman" label="联系人" width="180"> </el-table-column>
        <el-table-column prop="remark" label="备注"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini"> 编辑 </el-button>
            <el-button size="mini" type="danger">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[1, 2, 5, 10]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
    >
    </el-pagination>
  </div>
</template>

<script>
import api from "../../axios/api/api"; //封装axios请求

export default {
  data() {
    return {
      list: [],
      formInline: {
        user: "",
        region: "",
      },
      currentPage4: 1,
      pageSize: 1,
    };
  },
  methods: {
    handleSizeChange(val) {
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      this.currentPage4 = val;
    },
  },
  created() {
    api.gongyingslist(this.currentPage4, 2).then((res) => {
      this.list = res.data.data.rows;
    });
  },
  watch: {
    pageSize() {
      console.log(this.currentPage4);
      api.gongyingslist(this.currentPage4, this.pageSize).then((res) => {
        this.list = res.data.data.rows;
      });
    },
    currentPage4() {
      api.gongyingslist(this.currentPage4, this.pageSize).then((res) => {
        this.list = res.data.data.rows;
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
